<template>
  <avue-form
      ref="formRef"
      :option="null"
      @submit="submit"
      v-model="form">
    <template #menu-form="{}">

    </template>
  </avue-form>
  <el-divider/>
  <el-button type="primary"> 保存</el-button>
</template>
<script setup>

// import {userSelfUpdateDetailOption} from "@/views/system/user/js/UserOptions.js";

import {ref} from 'vue';
import {userSave} from "@/views/system/user/js/UserRequest.js";
import {useUserStore} from "@/store/index.js";

const userStore = useUserStore();

const formRef = ref(null)
const form = ref({});
const openAdd = ref(false)
form.value.username = userStore.userInfo.username

const success = ref(false)

const resetForm = () => {
  formRef.value.resetForm()
}

const submit = (form, done) => {
  userSave(form).then(res => {
    if (res.success) {
      success.value = true
    }
  }).finally(() => {
    if (success.value) {
      openAdd.value = false
      resetForm()
    }
    done()
  })
}
</script>

<style scoped>

</style>